<template>
  <a-layout
    :style="{
      height: this.$store.getters.getClientHeight + 'px',
      width: this.$store.getters.getClientWidth + 'px',
    }"
  >
    <a-layout-header class="header">
      <div class="logo" />
      <a-menu
        theme="dark"
        mode="horizontal"
        v-model:selectedKeys="selectedKeys1"
        :style="{ lineHeight: '64px' }"
      >
        <a-menu-item key="1" @click="changePage('BaseVue')"
          >VUE基础
        </a-menu-item>
        <a-menu-item key="2" @click="changePage('RouterVue')"
          >VUE Router
        </a-menu-item>
        <!-- <a-menu-item key="3">VUEX</a-menu-item> -->
        <a-menu-item key="4" @click="changePage('PiniaVue')">Pinia</a-menu-item>
      </a-menu>
    </a-layout-header>
    <a-layout>
      <a-layout-sider width="200" style="background: #fff">
        <a-menu
          mode="inline"
          v-model:selectedKeys="selectedKeys2"
          v-model:openKeys="openKeys"
          :style="{
            height: '100%',
            borderRight: 0,
          }"
          id="memuList"
        >
          <!-- vue -->
          <BaseVue v-if="pageName === 'BaseVue'"></BaseVue>
          <RouterVue v-if="pageName === 'RouterVue'"></RouterVue>
          <PiniaVue v-if="pageName === 'PiniaVue'"></PiniaVue>
        </a-menu>
      </a-layout-sider>
      <a-layout style="padding: 0 24px 24px">
        <div style="margin: 8px 0; color: rgb(0 205 112)">
          <span v-for="(item, index) of this.$route.matched" :key="index">
            <span style="margin-left: 4px">/ </span>
            <span> {{ item.meta.title }}</span>
          </span>
        </div>
        <a-layout-content
          :style="{
            background: '#fff',
            padding: '24px',
            margin: 0,
            minHeight: '280px',
            overflow: 'auto',
          }"
        >
          <!-- 子页面显示位置 -->
          <router-view v-slot="{ Component }">
            <transition name="fade">
              <component :is="Component" />
            </transition>
          </router-view>
        </a-layout-content>
      </a-layout>
    </a-layout>
  </a-layout>
</template>
<script>
import { defineComponent, ref } from "vue";
import BaseVue from "./vue/project-menu/BaseVue.vue";
import RouterVue from "./vue/project-menu/RouterVue.vue";
import PiniaVue from "./vue/project-menu/PiniaVue.vue";

export default defineComponent({
  components: {
    BaseVue,
    RouterVue,
    PiniaVue,
  },
  methods: {
    changePage(name) {
      this.pageName = name;
    },
  },
  data() {
    return {
      pageName: "BaseVue",
      selectedKeys1: ref(["0"]),
      selectedKeys2: ref(["0"]),
      collapsed: ref(false),
      openKeys: ref(["sub1"]),
    };
  },
});
</script>
<style scoped type="text/css">
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.5s ease;
}
.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}
#memuList {
  overflow: auto;
  overflow-x: hidden;
}

#components-layout-demo-top-side-2 .logo {
  float: left;
  width: 120px;
  height: 31px;
  margin: 16px 24px 16px 0;
  background: rgba(255, 255, 255, 0.3);
}

.ant-row-rtl #components-layout-demo-top-side-2 .logo {
  float: right;
  margin: 16px 0 16px 24px;
}

.site-layout-background {
  background: #fff;
}
</style>
